﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OSA.Policlinic.BusinessApplication.Registry;
using Policlinica;
using NLog;

namespace OSA.Policlinic.UI.WFApplication
{
    public partial class ChooseServiseForm : Form
    {
        private IRegistryBusinessApplication registryBusinessApplication;
        private List<MedService> medServices;
        public MedService choosedMedService;
        private static Logger logger = LogManager.GetCurrentClassLogger();

        public ChooseServiseForm()
        {
            InitializeComponent();
            registryBusinessApplication = RegistryBusinessApplicationHome.GetInstanse();
            medServices = registryBusinessApplication.GetAllMedServices();
            medServiceBindingSource.DataSource = registryBusinessApplication.GetAllMedServices();
            logger.Trace("Форма ChooseServiseForm успешно инициализирована");
        }

        private void medServiceDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                choosedMedService = (MedService) medServiceDataGridView.Rows[e.RowIndex].DataBoundItem;
                if(choosedMedService!=null)
                {
                    logger.Debug("Для выдачи талона выбрана услуга id = {0}", choosedMedService.Id);
                    this.Close();
                }
            }
        }
    }
}
